package com.demo3;

/**
 * Created by Administrator on 2017/3/25.
 */
public class ShuZu8 {
    public static void main(String[] args) {
        int[] intArray = {12, 11, 45, 6, 8, 43, 40, 57, 3, 20};
        int keyValue;
        int index;
        int temp;
        System.out.println("排序前的数组:");
        for (int i = 0; i < intArray.length; i++) {
            System.out.print(intArray[i] + "  ");
        }System.out.println();
        for (int i = 0; i < intArray.length; i++) {
            index = 1;
            keyValue = intArray[i];
            for (int j = i; j < intArray.length; j++)
                if (intArray[j] < keyValue) {
                    index = j;
                    keyValue = intArray[j];
                }
            temp = intArray[i];
            intArray[i] = intArray[index];
            intArray[index] = temp;
        }
        System.out.println("排序后的数组:");
        for (int i = 0; i < intArray.length; i++)
            System.out.print(intArray[i] + "  ");
    }

}
